package com.indusfo.spc.controller;

import com.indusfo.spc.aspect.SystemControllerLog;
import com.indusfo.spc.pojo.ProcessTarget;
import com.indusfo.spc.service.ProcessTargetService;
import com.indusfo.spc.vo.JSONObject;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;
import java.util.List;

/**
 * 工艺目标前端控制层
 *
 * @author xuz
 * @date 2018/12/6 5:03 PM
 */
@Controller
@RequestMapping("/processTarget")
public class ProcessTargetController {

	@Resource
	private ProcessTargetService processTargetService;

	/**
	 * 更新工艺目标
	 *
	 * @author xuz
	 * @date 2018/12/6 5:06 PM

	 * @return com.indusfo.spc.vo.JSONObject
	 */
	@RequestMapping(value="/updateProcessTarget", method= RequestMethod.POST)
	@SystemControllerLog(description="更新工艺目标信息")
	@ResponseBody
	public JSONObject updateProcessTarget(ProcessTarget processTarget) {

		JSONObject json = processTargetService.updateProcessTarget(processTarget);
		return json;
	}

	/**
	 * 新增工艺目标
	 *
	 * @author xuz
	 * @date 2018/12/6 5:06 PM
	 * @param [processTarget]
	 * @return com.indusfo.spc.vo.JSONObject
	 */
	@RequestMapping(value="/insertProcessTarget", method= RequestMethod.POST)
	@SystemControllerLog(description="新增工艺目标信息")
	@ResponseBody
	public JSONObject createProcessTarget(ProcessTarget processTarget) {

		JSONObject json = processTargetService.insertProcessTarget(processTarget);
		return json;
	}

	/**
	 * 查询工艺目标
	 *
	 * @author xuz
	 * @date 2018/12/6 5:06 PM
	 * @param [processTarget]
	 * @return com.indusfo.spc.vo.JSONObject
	 */
	@RequestMapping(value="/queryProcessTarget")
	@SystemControllerLog(description="查询工艺目标信息")
	@ResponseBody
	public JSONObject queryDep(ProcessTarget processTarget) {

		JSONObject json = processTargetService.queryProcessTarget(processTarget);
		return json;
	}

	/**
	 * 启用/停用
	 *
	 * @author xuz
	 * @date 2018/12/21 2:42 PM
	 * @param [lProTargets, lDataState]
	 * @return com.indusfo.spc.vo.JSONObject
	 */
	@RequestMapping(value="/definesProcessTarget", method= RequestMethod.POST)
	@SystemControllerLog(description="启用/停用工艺目标信息")
	@ResponseBody
	public JSONObject definesProcessTarget(@RequestParam("lProTargets")List<Integer> lProTargets, Integer lDataState) {

		JSONObject json = processTargetService.deleteProcessTarget(lProTargets, lDataState);
		return json;
	}

	/**
	 * 删除
	 *
	 * @author xuz
	 * @date 2018/12/6 5:07 PM
	 * @param [lProTargetS, lDataState]
	 * @return com.indusfo.spc.vo.JSONObject
	 */
	@RequestMapping(value="/deleteProcessTarget", method= RequestMethod.POST)
	@SystemControllerLog(description="删除工艺目标信息")
	@ResponseBody
	public JSONObject deleteProcessTarget(@RequestParam("lProTargets")List<Integer> lProTargets, Integer lDataState) {

		lDataState = 2;
		JSONObject json = processTargetService.deleteProcessTarget(lProTargets, lDataState);
		return json;
	}
}
